gsk: Avoid empty glyphs early
authorMatthias Clasen <mclasen@redhat.com>
Mon, 29 Mar 2021 00:22:24 +0000 (20:22 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 30 Mar 2021 04:34:52 +0000 (00:34 -0400)
Strip out PANGO_GLYPH_EMPTY when text nodes are
constructed. Then we don't have to check this special
case in the inner loop in visit_text_node.

gsk/gskrendernodeimpl.c
gsk/ngl/gsknglrenderjob.c

index d611977acc3b096635350225fd16133004dc7174..640c7922684d015c0ba9d739bf24c5711f599abe 100644 (file)
@@ -4435,9 +4435,15 @@ gsk_text_node_new (PangoFont              *font,
   self->has_color_glyphs = font_has_color_glyphs (font);
   self->color = *color;
   self->offset = *offset;
-  self->num_glyphs = glyphs->num_glyphs;
   self->glyphs = g_malloc_n (glyphs->num_glyphs, sizeof (PangoGlyphInfo));
-  memcpy (self->glyphs, glyphs->glyphs, glyphs->num_glyphs * sizeof (PangoGlyphInfo));
+
+  /* skip empty glyphs */
+  self->num_glyphs = 0;
+  for (int i = 0; i < glyphs->num_glyphs; i++)
+    {
+      if (glyphs->glyphs[i].glyph != PANGO_GLYPH_EMPTY)
+        self->glyphs[self->num_glyphs++] = glyphs->glyphs[i];
+    }
 
   graphene_rect_init (&node->bounds,
                       offset->x + ink_rect.x - 1,
index b45f33b7a8ab1770eb665ea9cedb6d958c2209ab..fa2c9c8cb9d2a90ed326c1cb6a4814da0a1b5c34 100644 (file)
@@ -2720,9 +2720,6 @@ gsk_ngl_render_job_visit_text_node (GskNglRenderJob     *job,
       float cy;
       guint texture_id;
 
-      if G_UNLIKELY (gi->glyph == PANGO_GLYPH_EMPTY)
-        continue;
-
       lookup.glyph = gi->glyph;
 
       cx = (float)(x_position + gi->geometry.x_offset) / PANGO_SCALE;